package com.bootdo.system.controller;

import com.bootdo.system.dao.JiaoyijiluDao;
import com.bootdo.system.domain.ApptupianDO;
import com.bootdo.system.domain.DayYingli;
import com.bootdo.system.domain.FormVO;
import com.bootdo.system.domain.JiaoyijiluDO;
import com.bootdo.system.service.ApptupianService;
import com.bootdo.system.service.FrontlogService;
import com.bootdo.system.service.JiaoyijiluService;
import com.bootdo.system.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.List;

@ResponseBody
@Controller
public class RecordController extends BaseController {

    @Autowired
    private JiaoyijiluService jiaoyijiluService;
    @Autowired
    private FrontlogService frontlogService;
    @Autowired
    private ApptupianService apptupianService;


    @GetMapping("/ezhangdan")
    public R ezhangdan(FormVO formVO, HttpServletRequest request) {

        //app图片
        ApptupianDO zhangdanleft = apptupianService.get(4);
        ApptupianDO zhangdanright = apptupianService.get(5);

        Long userId = getUserId(request);
        //交易账单
        formVO.setUserid(userId);
        List<JiaoyijiluDO> jiaoyijiluDOS = jiaoyijiluService.UserListAPI(formVO);

        //盈利
        BigDecimal today = jiaoyijiluService.getTodayYingli(userId);

        BigDecimal allyingli = jiaoyijiluService.getAllYingli(userId);

        return R.ok()
                .put("zhangdanleft",zhangdanleft)
                .put("zhangdanright",zhangdanright)
                .put("jiaoyijiluDOS",jiaoyijiluDOS)
                .put("today",today)
                .put("allyingli",allyingli);
    }

    @GetMapping("/bizhongjiluapi")
    public R bizhongjilu(Long  bizhongid, HttpServletRequest request) {

        //交易账单
        List<JiaoyijiluDO> jiaoyijiluDOS = jiaoyijiluService.bizhongjilu(getUserId(request),bizhongid);

        return R.ok().put("jiaoyijiluDOS",jiaoyijiluDOS);
    }

    @GetMapping("/ezhangdan/everydayYinli")
    public R everydayYinli(HttpServletRequest request) {

        List<DayYingli> dayYinglis = jiaoyijiluService.everydayYinli(getUserId(request));

        return R.ok().put("dayYinglis",dayYinglis);
    }

}
